#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>


int main()
{
    
    pid_t id=fork();
    if(id<0)
    {
        perror("fork");
        return -1;
    }
    else if(id==0)
    {
        printf("I am child process!My pid::%d,My ppid::%d\n",getpid(),getppid());
        sleep(10);
    }
    else
    {
        printf("I am parent process!My pid::%d,My ppid::%d\n",getpid(),getppid());
        int status=0;
        pid_t ret=waitpid(id,&status,0);
        if(ret<0)
        {
            printf("Waiting failed!\n");
        }
        else{
            printf("Wating success!ret::%d,exit code::%d,signal::%d\n",ret,(status>>8)&0xFF,status&0x7F);
        }
    }
    return 0;

}
